//
//  YWSelectContanctCell.m
//  maintain
//
//  Created by Kyo on 16/8/30.
//  Copyright © 2016年 ewin. All rights reserved.
//

#import "YWSelectContanctCell.h"
#import "UIImageView+WebCache.h"
#import "YWCommonTool.h"
#import "YWMacro.h"
#import "YWHandler.h"
#import "UIView+Extension.h"

@implementation YWSelectContanctCell

+ (instancetype)cellWithTableView:(UITableView *)tableView
{
    static NSString *identifier = @"YWSelectContanctCellCellIdentifier";
    YWSelectContanctCell *cell = [tableView dequeueReusableCellWithIdentifier:identifier];
    if (cell == nil) {
        cell = [[YWSelectContanctCell alloc]initWithStyle:UITableViewCellStyleSubtitle reuseIdentifier:identifier];
        cell.layer.shouldRasterize = YES;
        cell.layer.rasterizationScale = [UIScreen mainScreen].scale;
    }
    return cell;
}

- (void)setContact:(YWHandler *)contact{
    _contact = contact;
    NSString* downloadUrl = [YWCommonTool pictureDownloadUrl:contact.headIcon];
    [self.imageView sd_setImageWithURL:[NSURL URLWithString:downloadUrl] placeholderImage:[UIImage imageNamed:@"profile_headimage"]];
    self.textLabel.text = contact.userName?:@"";
}

- (void)layoutSubviews{
    [super layoutSubviews];
    self.imageView.frame = CGRectMake(10, 10, 40, 40);
    self.imageView.clipsToBounds = YES;
    self.imageView.layer.cornerRadius = 40/2.0f;
    
    self.textLabel.font = kContentFont;
    self.textLabel.x = CGRectGetMaxX(self.imageView.frame)+15;
}
@end
